<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>正泰电力服务后台</title>
    <script type="text/javascript" src="../../statics/js/jquery-1.12.4.js"></script>
    <link rel="stylesheet" href="login/css/amend.css"/>
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <!-- 提示升级高级浏览器操作 -->
    <style>
        .ie-content{  position: fixed; left: 0; top: 0; right: 0; bottom:0; background:#fff; z-index: 1000;}
        .ie-content-bj{ width: 1000px; height: 380px; position: fixed; left: 50%; top: 36%; margin:-190px 0 0 -500px; background:url(img/sj.jpg) no-repeat; }
        .ie-list{ padding:168px 0 0 371px; }
        .ie-list a{ margin-right: 80px; }
    </style>
</head>
<body class="body_bj">

<div class="login" style="height: 300px;">

    <ul class="login-list">
        <form class="layui-form" action="">
            <li><input type="text"  placeholder="请输入新密码" class="layui-input" id="password" name="password"><span id="ps2"></span></li>
            <li><input type="text"  placeholder="请再次输入新密码" class="layui-input" id="newpassword" name="password"><span id="ps3"></span></li>
            <li>
                <button lay-filter="submit_new_password" lay-submit=""
                        class="layui-btn" id="button" style=" width:94%;">确 定</button>
                <!-- <div lay-filter="submit_reject_reason" lay-submit=""
                        class="layui-btn" style=" min-width: 145px;" id="esc">取消</div>
                        <span id="ps4"></span> -->
            </li>

        </form>
    </ul>
</div>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script>
    layui.use(['jquery','form'], function(){
        var $ = layui.jquery,form = layui.form,layer = layui.layer;

        $("#password").blur(function(){
            if($("#password").val() == null ||$("#password").val() == ""){
                $("#ps2").html("<label style='color: red;'>输入框不能为空</label>");
            }else if(!(/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,20}$/.test($("#password").val()))){
                $("#ps2").html("<label style='color: red;'>请输入6-20位的字母、数字、符号任意两种的组合密码</label>");
                $("#password").val("");
            }else{
                $("#ps2").html("<label style='color: green;'>√</label>");
            }
        });

        $("#newpassword").blur(function(){
            if($("#newpassword").val() == null ||$("#newpassword").val() == ""){
                $("#ps3").html("<label style='color: red;'>输入框不能为空</label>");
            }else if($("#password").val()!= $("#newpassword").val()){
                $("#ps3").html("<label style='color: red;'>两次密码不一致，重新输入！</label>");
                $("#newpassword").val("");
            }else if($("#password").val() == null || $("#password").val()== ""){
                $("#ps3").html("<label style='color: red;'>请按顺序填写！</label>");
                $("#newpassword").val("");
            } else {
                $("#ps3").html("<label style='color: green;'>密码一致</label>");
            }
        });

        var lock = false;
        form.on('submit(submit_new_password)', function(data){
            var password = $("#password").val();
            if(password == null ||password == ""){
                $("#ps2").html("<label style='color: red;'>输入框不能为空</label>");
                return false;
            }else if(!(/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,20}$/.test(password))){
                $("#ps2").html("<label style='color: red;'>请输入6-20位的字母、数字、符号任意两种的组合密码</label>");
                $("#password").val("");
                return false;
            }else{
                $("#ps2").html("<label style='color: green;'>√</label>");
            }
            var newpassword=$("#newpassword").val();
            if(newpassword == null ||newpassword == ""){
                $("#ps3").html("<label style='color: red;'>输入框不能为空</label>");return false;
            }else if(password!= newpassword){
                $("#ps3").html("<label style='color: red;'>两次密码不一致，重新输入！</label>");
                $("#newpassword").val("");return false;
            }else if($("#password").val() == null || $("#password").val()== ""){
                $("#ps3").html("<label style='color: red;'>请按顺序填写！</label>");
                $("#newpassword").val("");return false;
            } else {

                if (!lock) {
                    lock = true;
                    $.ajax({
                        type: "POST",
                        url: '../../web/amend',
                        //async:false,
                        data: {
                            password: password
                        },
                        dataType: "json",

                        success: function (data) {
                            if (data.status == "50") {
                                //lock = false;
                                layer.msg(data.msg, {icon: 1});
                                setTimeout("wait_exe()", 1000);

                            } else {
                                //lock = false;
                                layer.msg(data.msg, {icon: 5, time: 1000});

                            }
                        }
                    });
                } else {
                    alert("正在处理！");
                }
            }
            return false;
        });


    });

    function wait_exe (){
        window.parent.location.href="../../web/exit_login";
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
    }
</script>

</body>
</html>